package tool

import play.api.data.Form
import play.api.data.Forms._
import tool.Pojo._

/**
 * Created by yz on 16/9/2021
 */
object FormTool {

  val accountForm = Form(
    mapping(
      "account" -> text
    )(AccountData.apply)(AccountData.unapply)
  )

  val qForm = Form(
    mapping(
      "q" -> text,
      "page" -> number,
      "pageSize" -> number,
    )(QData.apply)(QData.unapply)
  )

  val userForm = Form(
    mapping(
      "account" -> text,
      "password" -> text
    )(UserData.apply)(UserData.unapply)
  )

  val changePasswordForm = Form(
    mapping(
      "password" -> text,
      "newPassword" -> text
    )(ChangePasswordData.apply)(ChangePasswordData.unapply)
  )

  val sampleNameForm = Form(
    mapping(
      "sampleName" -> text
    )(SampleNameData.apply)(SampleNameData.unapply)
  )

  val sampleForm = Form(
    mapping(
      "id" -> number,
      "sampleName" -> text,
      "describe" -> text
    )(SampleData.apply)(SampleData.unapply)
  )

  val describeForm = Form(
    mapping(
      "describe" -> text
    )(DescribeData.apply)(DescribeData.unapply)
  )

  val idsForm = Form(
    mapping(
      "ids" -> list(number)
    )(IdsData.apply)(IdsData.unapply)
  )

  val idForm = Form(
    mapping(
      "id" -> number
    )(IdData.apply)(IdData.unapply)
  )

  val rangeForm = Form(
    mapping(
      "range" -> text
    )(RangeData.apply)(RangeData.unapply)
  )

  val pathForm = Form(
    mapping(
      "path" -> text
    )(PathData.apply)(PathData.unapply)
  )

  val idOpForm = Form(
    mapping(
      "id" -> optional(number)
    )(IdOpData.apply)(IdOpData.unapply)
  )

  val queryForm = Form(
    mapping(
      "method" -> text,
      "queryText" -> text,
      "db" -> text,
      "evalue" -> text,
      "wordSize" -> text,
      "maxTargetSeqs" -> text
    )(QueryData.apply)(QueryData.unapply)
  )

  val nameForm = Form(
    mapping(
      "name" -> text
    )(NameData.apply)(NameData.unapply)
  )

  val kindForm = Form(
    mapping(
      "kind" -> text
    )(KindData.apply)(KindData.unapply)
  )

  val missionNameForm = Form(
    mapping(
      "missionName" -> text
    )(MissionNameData.apply)(MissionNameData.unapply)
  )

  val missionForm = Form(
    mapping(
      "missionName" -> text,
      "missionIntro" -> text,
      "db" -> text,
      "trim5" -> text,
      "trim3" -> text,
      "threadNum" -> number,
    )(MissionData.apply)(MissionData.unapply)
  )

  val missionIdForm = Form(
    mapping(
      "missionId" -> number
    )(MissionIdData.apply)(MissionIdData.unapply)
  )

  val fileNameForm = Form(
    mapping(
      "fileName" -> text
    )(FileNameData.apply)(FileNameData.unapply)
  )

  val columnNameForm = Form(
    mapping(
      "columnName" -> text
    )(ColumnNameData.apply)(ColumnNameData.unapply)
  )

  val missionIdOptionForm = Form(
    mapping(
      "missionId" -> optional(number)
    )(MissionIdOptionData.apply)(MissionIdOptionData.unapply)
  )

  val geneIdForm = Form(
    mapping(
      "geneId" -> text
    )(GeneIdData.apply)(GeneIdData.unapply)
  )

  val speciesForm = Form(
    mapping(
      "species" -> text
    )(SpeciesData.apply)(SpeciesData.unapply)
  )

  val geneNameForm = Form(
    mapping(
      "geneName" -> text
    )(GeneNameData.apply)(GeneNameData.unapply)
  )

  val geneTypeOpForm = Form(
    mapping(
      "geneType" -> optional(text)
    )(GeneTypeData.apply)(GeneTypeData.unapply)
  )

  val tabOpForm = Form(
    mapping(
      "tab" -> optional(text)
    )(TabOpData.apply)(TabOpData.unapply)
  )

  val geneNameOpForm = Form(
    mapping(
      "geneName" -> optional(text)
    )(GeneNameOpData.apply)(GeneNameOpData.unapply)
  )

  val regionForm = Form(
    mapping(
      "chr" -> text,
      "start" -> number,
      "end" -> number
    )(RegionData.apply)(RegionData.unapply)
  )

  val keywordForm = Form(
    mapping(
      "keyword" -> text
    )(KeywordData.apply)(KeywordData.unapply)
  )

  val blastForm = Form(
    mapping(
      "queryText" -> optional(text),
      "againstType" -> text,
      "evalue" -> text,
      "wordSize" -> text,
      "maxTargetSeqs" -> text
    )(BlastData.apply)(BlastData.unapply)
  )

  val regionStrForm = Form(
    mapping(
      "region" -> text
    )(RegionStrData.apply)(RegionStrData.unapply)
  )

  val keggEnrichForm = Form(
    mapping(
      "geneId" -> optional(text),
      "database" -> text,
      "method" -> text,
      "fdr" -> text,
      "cutoff" -> text,
      "pValue" -> text
    )(KeggEnrichData.apply)(KeggEnrichData.unapply)
  )

  val muscleForm = Form(
    mapping(
      "queryText" -> optional(text),
      "tree" -> text
    )(MuscleData.apply)(MuscleData.unapply)
  )

  val svgForm = Form(
    mapping(
      "svgHtml" -> text
    )(SvgData.apply)(SvgData.unapply)
  )

  val primerForm = Form(
    mapping(
      "species" -> text,
      "chr" -> text,
      "start" -> text,
      "end" -> text,
      "SEQUENCE_TARGET" -> text,
      "PRIMER_PRODUCT_SIZE_RANGE" -> text,
      "PRIMER_OPT_SIZE" -> text,
      "PRIMER_MAX_SIZE" -> text,
      "PRIMER_MIN_SIZE" -> text,
      "PRIMER_OPT_TM" -> text,
      "PRIMER_MAX_TM" -> text,
      "PRIMER_MIN_TM" -> text,
      "PRIMER_OPT_GC_PERCENT" -> text,
      "PRIMER_MAX_GC" -> text,
      "PRIMER_MIN_GC" -> text,
      "PRIMER_MAX_NS_ACCEPTED" -> text,
      "PRIMER_MAX_POLY_X" -> text,
      "PRIMER_INTERNAL_MAX_POLY_X" -> text,
      "PRIMER_MAX_SELF_ANY" -> text,
      "PRIMER_MAX_SELF_END" -> text,
      "PRIMER_PAIR_MAX_COMPL_ANY" -> text,
      "PRIMER_PAIR_MAX_COMPL_END" -> text
    )(primerData.apply)(primerData.unapply)
  )

  val primerForm2 = Form(
    mapping(
      "method" -> text,
      "queryText" -> text
    )(primerData2.apply)(primerData2.unapply)
  )

  val mummerForm = Form(
    mapping(
      "targetText" -> optional(text),
      "queryText" -> optional(text)
    )(MummerData.apply)(MummerData.unapply)
  )

  val geneWiseForm = Form(
    mapping(
      "method" -> text,
      "proteinSeq" -> text,
      "geneId" -> text,
      "dnaSeq" -> text,
      "para" -> boolean,
      "pretty" -> boolean,
      "genes" -> boolean,
      "trans" -> boolean,
      "cdna" -> boolean,
      "embl" -> boolean,
      "ace" -> boolean,
      "gff" -> boolean,
      "diana" -> boolean,
      "init" -> text,
      "splice" -> text,
      "random" -> text,
      "alg" -> text
    )(GeneWiseData.apply)(GeneWiseData.unapply)
  )

  val pageForm = Form(
    mapping(
      "limit" -> number,
      "offset" -> number,
    )(PageData.apply)(PageData.unapply)
  )

  val keysForm = Form(
    mapping(
      "keys" -> list(text),
    )(KeysData.apply)(KeysData.unapply)
  )

}
